package com.matrix.java.chap_06;

/*
    游戏：双骰儿赌博
 */
public class Ex6_30 {
    public static void main(String[] args) {
        int num1 = (int) (Math.random() * 6);
        int num2 = (int) (Math.random() * 6);
        int result = num1 + num2;
        int temp = result;
        System.out.println("You rolled " + num1 + "+" + num2 + "=" + result);
        resultCheck(result, temp);
    }

    private static void resultCheck(int result, int temp) {
        int num1;
        int num2;
        if (result == 2 || result == 3 || result == 12) {
            System.out.println("You lose");
        } else if (result == 7 || result == 11) {
            System.out.println("You win");
        } else {
            System.out.println("point is " + result);
            do {
                num1 = (int) (Math.random() * 6);
                num2 = (int) (Math.random() * 6);
                result = num1 + num2;
            } while (result != 7 && result != temp);
            System.out.println("You rolled " + num1 + "+" + num2 + "=" + result);
            if (result == 7) {
                System.out.println("You lose");
            } else {
                System.out.println("You win");
            }
        }
    }
}
